package com.qf.dao.impl;

import com.qf.dao.UserDao;
import com.qf.entity.User;
import com.qf.util.DruidUtil;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanHandler;

import java.sql.SQLException;

/*
杨威
2021/9/19
17:47
*/
public class UserDaoImpl implements UserDao {
    QueryRunner queryRunner=new QueryRunner();
    @Override
    public User selectByUserName(String userName) {
        String sql="select * from user where username=?";
        User user = null;
        try {
            user = queryRunner.query(DruidUtil.getConnection(), sql, new BeanHandler<>(User.class), userName);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return user;
    }
}
